package com.fr.web.core;

import com.fr.base.core.html.Tag;
import com.fr.report.ReportGetter;
import com.fr.web.Browser;
import com.fr.web.Repository;
import com.fr.web.core.chwriter.CellHtmlWriter;
import com.fr.web.core.chwriter.TreeCellWriter;
import java.awt.Rectangle;
import java.util.HashSet;
import java.util.Iterator;

public class TreeHTMLWriter extends HTMLWriter
{
  private Tag[] trs;
  private Tag[][] tds;

  public static HTMLWriter getInstance()
  {
    return new TreeHTMLWriter();
  }

  protected Tag clipReport2Html(ReportGetter paramReportGetter, Rectangle paramRectangle, int paramInt, CellHtmlWriter paramCellHtmlWriter, Repository paramRepository)
  {
    this.trs = new Tag[paramRectangle.height];
    this.tds = new Tag[paramRectangle.height][paramRectangle.width];
    Tag localTag = super.clipReport2Html(paramReportGetter, paramRectangle, paramInt, paramCellHtmlWriter, paramRepository);
    if (paramCellHtmlWriter instanceof TreeCellWriter)
    {
      int i;
      Iterator localIterator;
      int j;
      HashSet localHashSet1 = ((TreeCellWriter)paramCellHtmlWriter).tree_dn_rowIndex;
      HashSet localHashSet2 = ((TreeCellWriter)paramCellHtmlWriter).tree_dn_columnIndex;
      if ((localHashSet1 != null) && (localHashSet1.size() > 0))
      {
        Tag[] arrayOfTag;
        localIterator = localHashSet1.iterator();
        do
        {
          do
          {
            do
            {
              if (!(localIterator.hasNext()))
                break label315;
              i = ((Integer)localIterator.next()).intValue();
            }
            while ((this.trs[(i - paramRectangle.y)] == null) || (paramReportGetter.getRowHeight(i) == 0));
            this.trs[(i - paramRectangle.y)].cls("tntr").css("display", "none");
          }
          while (!("msie".equals(paramRepository.getBrowser().getBrowser())));
          arrayOfTag = this.tds[(i - paramRectangle.y)];
        }
        while (arrayOfTag == null);
        j = 0;
        while (true)
        {
          if (j >= arrayOfTag.length);
          if ((arrayOfTag[j] != null) && (paramReportGetter.getColumnWidth(j + paramRectangle.x) != 0) && (((localHashSet2 == null) || (!(localHashSet2.contains(new Integer(j + paramRectangle.x)))))))
            arrayOfTag[j].cls("tntd").css("display", "none").attr("tdcol", "" + (j + paramRectangle.x));
          ++j;
        }
      }
      if ((localHashSet2 != null) && (localHashSet2.size() > 0))
      {
        label315: localIterator = localHashSet2.iterator();
        do
        {
          if (!(localIterator.hasNext()))
            break label487;
          i = ((Integer)localIterator.next()).intValue();
        }
        while (paramReportGetter.getColumnWidth(i) == 0);
        j = 0;
        while (true)
        {
          if (j >= this.tds.length);
          if ((this.tds[j] != null) && (this.tds[j][(i - paramRectangle.x)] != null) && (paramReportGetter.getRowHeight(j + paramRectangle.y) != 0))
            this.tds[j][(i - paramRectangle.x)].cls("tntd").css("display", "none").attr("tdcol", "" + i);
          ++j;
        }
      }
    }
    label487: return localTag;
  }

  protected void dealWithTrTag(Tag paramTag, int paramInt)
  {
    this.trs[paramInt] = paramTag;
  }

  protected void dealWithTdTag(Tag paramTag, int paramInt1, int paramInt2)
  {
    this.tds[paramInt2][paramInt1] = paramTag;
  }
}